#include "precompiled.h"
#include "equipcom.h"
using namespace weo::engine::character;
using namespace weo::engine::item;
using namespace std;
bool Equipcom::s_UseSpecial = true;
bool Equipcom::s_UseWeaponProcs = true;
Equipcom::Equipcom()
{
    m_Mode = 0;
    ResetBase();
    ResetBuffs();
    ResetEquip();
    ResetTest();
}
float Equipcom::Get(const unsigned int index) const
{
    switch(m_Mode)
    {
    case 0:
        return m_Base[index];
        break;
    case 1:
        return m_Buff[index];
        break;
    case 2:
        return m_Equip[index];
        break;
    case 3:
        return m_Base[index] + m_Buff[index] + m_Equip[index];
        break;
    case 4:
        return m_Test[index];
    default:
        return m_Base[index] + m_Buff[index] + m_Equip[index];
        break;
    }
}
void Equipcom::Set(const unsigned int index, const float value)
{
    switch(m_Mode)
    {
    case 0:
        m_Base[index] = value;
        break;
    case 1:
        m_Buff[index] = value;
        break;
    case 2:
        m_Equip[index] = value;
        break;
    case 4:
        m_Test[index] = value;
    default:
        break;
    }
}
float& Equipcom::operator[](const unsigned int index)
{
    switch(m_Mode)
    {
    case 0:
        return m_Base[index];
        break;
    case 1:
        return m_Buff[index];
        break;
    case 2:
        return m_Equip[index];
        break;
    case 3:
        {
            m_Combined[index] =  m_Base[index]+ m_Buff[index] + m_Equip[index];
            return m_Combined[index];
            break;
        }
    case 4:
        return m_Test[index];
        break;
    default:
        break;
    }
}
Attribute Equipcom::handleSpecial(unsigned int value)
{
    if(!Equipcom::s_UseSpecial) return Attribute("None",0);
    switch(value)
    {
    case 1000010:
        {
            if(!Equipcom::s_UseWeaponProcs) return  Attribute("None",0);
            return Attribute("Agility",0.35f*120); // mongoose
            break;
        }
    case 1000011:
        {
            if(!Equipcom::s_UseWeaponProcs) return  Attribute("None",0);
            return Attribute("HasteRating",0.35f*2*weo::engine::item::HasteRating); // mongoose
            break;
        }
    case 1036724:
        {
            return Attribute("AttackPower",56.67f); // tsunami talisman
        }
    case 1321365:
        {
            return Attribute("ArmorPenetration",100); // madness of the betrayer, assume 1/3 uptime
        }
    case 964406:
        {
            return Attribute("HasteRating",81.25f); // dst, 1.5ppm
        }
    case 910684:
        {
            return Attribute("SpellDamage",90/6.0f); // band of the eternal sage 1ppm (10s runtime, 60s cd = /5)
        }
    case 706596:
        {
            return Attribute("Healing",175/6.0f); // band of the eternal restorer 1ppm
        }
    case 1434410:
        {
            return Attribute("MP5",19); // memento of tyrande (228 mana each minute) // 1 proc
        }
    case 931517:
        {
            return Attribute("Healing",100); // fel reavers piston, close to 5ppm
        }
    case 39963:
        {
            return Attribute("MP5",12); // insightful earthstorm diamond
        }
    case 708087:
        {
            return Attribute("HasteRating",212.0f/6.0f); //drakefist etc -  assume one ppm 
        }
    case 837706:
        {
            return Attribute("HasteSpellRating",175.0f/6.0f); // Skull of Guldan
        }
    case 278280:
        {
            return Attribute("HasteRating",450*0.125); //assume 0.75ppm for dual warglaives
        }
    case 9965:
        {
            return Attribute("AttackPower",275/6.0f); //bloodlust brooch
        }
    case 1257015:
        {
            return Attribute("SpellDamage",155/6.0f); // silver crescent
        }
    case 247092:
        {
            return Attribute("CritSpellRating",12); // chaos metagem
        }
    case 1410705:
        {
            return Attribute("AttackPower",360/6.0f); // berserkers call
        }
    default:
        switch(m_Mode)
        {
        case 0:
            m_SpecialsBase.insert(value);
            break;
        case 1:
            m_SpecialsBuff.insert(value);
            break;
        case 2:
            m_SpecialsEquip.insert(value);
            break;
        case 3:
            break; // should never happen no insert in mode 3 (running)
        case 4:
            m_SpecialsTest.insert(value);
            break;
        default:
            break;
        }
        return Attribute("None",0);
        break;
    }
}
bool Equipcom::hasSpecial(float value)
{
    if(m_SpecialsBase.count(value) > 0 || m_SpecialsBuff.count(value) > 0 || m_SpecialsEquip.count(value) > 0 || m_SpecialsTest.count(value) > 0) return true;
    return false;
}